import asyncio
import time
import httpx
async def req(client, i):
    res = await client.get('http://www.techlabplt.com:8080/BD-PC/priceList')
    print(f'第{i + 1}次请求，status_code = {res.status_code}')
    return res
async def main():
    async with httpx.AsyncClient(timeout = None) as client:
        task_list = []  # 任务列表
        for i in range(300):
            res = req(client, i)
            task = asyncio.create_task(res)  # 创建任务
            task_list.append(task)
        await asyncio.gather(*task_list)  # 收集任务
if __name__ == '__main__':
    start = time.time( )
    asyncio.run (main( ))
    end = time.time( )
    print (f'异步发送300次请求，耗时：{end - start}')
